-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Implement Decode
, Encode
and Type
for Box
, Arc
, Cow
and Rc
#3674
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Decode
, Encode
and Type
for Box
, Arc
, Cow
and Rc
@joeydewaal technically it's still possible to use by getting the We can relax the sqlx/sqlx-core/src/query_as.rs Line 111 in 277dd36
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Previous comment.
676e11e
to
f2930a6
Compare
Makes sense, I added the impl for |
CI should be fixed if you rebase. |
9d694c0
to
b6521ae
Compare
b59de52
to
3857c69
Compare
608908c
to
c68cf4b
Compare
eb5b015
to
2da2978
Compare
2da2978
to
bf09881
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you wouldn't mind, let's just commit to making the Decode
for Cow
impl return Cow::Owned
.
Right, that should be reflected in the latest changes. |
impl<'r, 'a, DB> Decode<'r, DB> for Cow<'a, str> | ||
where | ||
DB: Database, | ||
String: Decode<'r, DB>, | ||
{ | ||
fn decode(value: <DB as Database>::ValueRef<'r>) -> Result<Self, BoxDynError> { | ||
<String as Decode<DB>>::decode(value).map(Cow::Owned) | ||
} | ||
} | ||
|
||
impl<'r, 'a, DB> Decode<'r, DB> for Cow<'a, [u8]> | ||
where | ||
DB: Database, | ||
Vec<u8>: Decode<'r, DB>, | ||
{ | ||
fn decode(value: <DB as Database>::ValueRef<'r>) -> Result<Self, BoxDynError> { | ||
<Vec<u8> as Decode<DB>>::decode(value).map(Cow::Owned) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think these aren't necessary if you add T: ?Sized
to the generic impl.
fixes #3100
Implements
Decode
,Encode
andType
forBox<T>
,Arc<T>
,Cow<'_,T>
andRc<T>
. I left out theDecode
impl forRc<T>
because of theSend
trait bounds inQueryAs
andQueryScalar
(which makes it impossible to useRc
).